<template>
  <a-card :bordered="false">
    <!-- table区域-begin -->
    <div>
      <vxe-grid
        style="width: 100%;"
        :height="curHeight"
        size="mini"
        align="center"
        highlight-hover-row
        stripe
        row-key
        row-id="selectedRowKeys"
        column-min-width="150"
        id="id"
        keep-source
        :loading="loading"
        border
        resizable
        auto-resize
        showOverflow
        showHeaderOverflow
        :pager-config="tablePage"
        ref="xGrid"
        :row-config="{ useKey: true,keyField: 'id',isCurrent:true,isHover:true}"
        :checkbox-config="{
          checkRowKeys:selectedRowKeys,
          trigger: 'row',
          highlight: true,
          reserve: true}"
        @sort-change="sortChange"
        @checkbox-change="checkboxChangeEvent"
        @checkbox-all="checkboxChangeEvent"
        :data="dataSource"
        :columns="columns"
        @page-change="handlePageChange"
      >
        <template v-slot:top>
          <div class="table-operator">
            <a-button type="primary" icon="plus" @click="handleAdd">新增</a-button>
            <!-- 高级查询区域 -->
            <j-super-query :fieldList="superFieldList" ref="superQueryModal"
                           @handleSuperQuery="handleSuperQuery"></j-super-query>
            <a-dropdown v-if="selectedRowKeys.length > 0">
              <a-menu slot="overlay">
                <a-menu-item key="1" @click="batchDel">
                  <a-icon type="delete"/>
                  删除
                </a-menu-item>
              </a-menu>
              <a-button type="primary" icon="down">批量操作</a-button>
            </a-dropdown>
          </div>
        </template>
        <template v-slot:operate="{ row }">
          <a-button  type="primary" shape="circle" @click="handleEdit(row)" icon="edit"/>
<!--          <a-button v-if="row.status == 0" type="primary" shape="circle" @click="handleEdit(row)" icon="edit"/>-->
<!--          <a-button v-else type="primary" shape="circle" @click="handleEdit(row)" icon="edit" disabled/>-->
          <a-divider type="vertical"/>
          <a-dropdown>
            <a-button type="primary" shape="circle" class="ant-dropdown-link" icon="setting"/>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(row)">详情</a>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </template>
        <template v-slot:empty>
          <a-empty/>
        </template>
      </vxe-grid>
    </div>
    <!-- table区域-end -->
    <wcs-four-way-task-modal ref="modalForm" @ok="modalFormOk"></wcs-four-way-task-modal>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import {mixinDevice} from '@/utils/mixin'
import {HYListMixin} from '@/mixins/HYListMixin'
import WcsFourWayTaskModal from './modules/WcsFourWayTaskModal'

export default {
  name: 'WcsFourWayTaskList',
  mixins: [HYListMixin, mixinDevice],
  components: {
    WcsFourWayTaskModal
  },
  data() {
    return {
      description: '四向车任务表管理页面',
      // 表头
      columns: [
        {type: "checkbox", width: 50, align: "center"},//多选
        {type: "seq", width: 50, align: "center"},//
        {title: 'WCS任务Id', align: "center", field: 'id'},
        {title: 'WMS任务Id', align: "center", field: 'relateCode'},
        {title: '任务类型', align: "center", field: 'taskType'},
        {title: '任务状态', align: "center", field: 'taskStatus'},
        {title: 'RGV执行进度', align: "center", field: 'rgvProgress'},
        {title: '优先级', align: "center", field: 'priority'},
        {title: '起点', align: "center", field: 'source'},
        {title: '终点', align: "center", field: 'target'},
        {title: '托盘号', align: "center", field: 'palletNo'},
        {title: '是否分配车辆', align: "center", field: 'assignStatus'},
        {title: '执行车辆Id', align: "center", field: 'processRgvDeviceCode'},

        {title: '操作', fixed: 'right', width: 105, slots: {default: 'operate'}}
      ],
      url: {
        list: "/wcs/wcsFourWayTask/list",
        delete: "/wcs/wcsFourWayTask/delete",
        deleteBatch: "/wcs/wcsFourWayTask/deleteBatch",
        exportXlsUrl: "/wcs/wcsFourWayTask/exportXls",
        importExcelUrl: "wcs/wcsFourWayTask/importExcel",

      },
      dictOptions: {},
      superFieldList: [],
    }
  },
  created() {
    this.getSuperFieldList();
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    initDictConfig() {
    },
    getSuperFieldList() {
      let fieldList = [];
      fieldList.push({type: 'string', value: 'relateCode', text: '业务单据号', dictCode: ''})
      fieldList.push({type: 'string', value: 'taskNo', text: '任务号', dictCode: ''})
      fieldList.push({type: 'int', value: 'taskStatus', text: '任务状态', dictCode: ''})
      fieldList.push({type: 'int', value: 'serialNo', text: '流水号(设备)', dictCode: ''})
      fieldList.push({type: 'string', value: 'palletNo', text: '托盘号', dictCode: ''})
      fieldList.push({type: 'string', value: 'source', text: '起点', dictCode: ''})
      fieldList.push({type: 'string', value: 'target', text: '终点', dictCode: ''})
      fieldList.push({type: 'int', value: 'priority', text: '优先级', dictCode: ''})
      fieldList.push({type: 'int', value: 'taskType', text: '任务类型', dictCode: ''})
      fieldList.push({type: 'string', value: 'plcNo', text: 'plc编号', dictCode: ''})
      fieldList.push({type: 'datetime', value: 'sendTime', text: '下发到PLC时间'})
      fieldList.push({type: 'datetime', value: 'startTime', text: '任务开始时间'})
      fieldList.push({type: 'datetime', value: 'finishTime', text: '任务结束时间'})
      fieldList.push({type: 'string', value: 'remark', text: '备注', dictCode: ''})
      this.superFieldList = fieldList
    }
  }
}
</script>



<style scoped>
  @import "~@assets/less/common.less";
</style>